<?php
session_start();
$username = strtolower($_POST['username']) or $_COOKIE['username'];
$password = $_POST['password'] or $_COOKIE['password'];
include('config.php');
//echo $_SESSION['error'];
if(isset($_POST['submit']) or isset($_COOKIE['username']))
{
	$ok = mysql_query("Select * from account where id = '$username' and password = '$password'");
	if(mysql_num_rows($ok) == 0)
	{
		$notice = "Sai tài khoản hoặc mật khẩu";
	}
	if(mysql_num_rows($ok) > 0 and isset($_COOKIE['username']))
	{
		header('Location: member.php');
	//header('Location: chonser/chonserver.php');
	}
	if(mysql_num_rows($ok) > 0 and $_COOKIE['username'] == "")
	{
		setcookie("username",$username,time() + 1800);
		setcookie("password",$password,time() + 1800);
		header('Location: member.php');
		//header('Location: chonser/chonserver.php');
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Đao Kiếm Vô Tình Online</title>
<link href="css/styles.css" rel="stylesheet" type="text/css"/>
<script src="js/ga.js"></script>
<?
if($_GET['do'] == '1'){?><script>alert('Đăng ký thành công! Vui lòng đăng nhập.');</script>

<?}

?>
</head>
<body>
<div id="container">
  <div class="close-beta"><img src="images/top_center.png" width="772" height="143" /></div>
  <div class="main-content">
    <div class="dangky"> <a href="login.php" target="">
      <div class="choi-ngay">&nbsp;</div>
      </a> <a href="regis.php" target="_blank">
      <div class="dang-ky">&nbsp;</div>
      </a> <a href="nap-the.php">
      <div class="nap-the">&nbsp;</div>
      </a> </div>
    <div class="regis">
     <h1><img src="images/title_logi.png" width="93" height="27" /></h1>
    <form id="loginForm" name="loginForm" method="post" action="login.php">
   		<div style="text-align:center; color:#FFF;font-size:16px;font-weight:bold;padding-bottom:10px;">Thiên Mệnh</div>
   		<label>Tên đăng nhập</label>
      <input type="text" name="username" id="username" value="" helper="formText" placeholder="Tài Khoản"/>
      <br/>
      <label>Mật khẩu</label>
      <input type="password" name="password" id="password" value="" helper="formPassword" placeholder="Mật Khẩu"/>
      <br/>
      <tr><font color='red'><?php echo $notice;?></font></tr>
      <div style="display:inline-block;">
      <input type="submit" name="submit" id="loginForm" value="&nbsp;" class="sub btnDNhap" />
      <a class="reg_button" href="regis.php" target="_blank">&nbsp;</a></div>
    </form>
   </div>
    <div class="forum-main"> <a href="/"><img src="images/logo.png" width="220" height="249" /></a> <a href="http://diendan.daokiemvotinh.com" target="_blank">
      <div class="diendan">&nbsp;</div>
      </a> <a href="http://www.facebook.com/pages/%C4%90ao-Ki%E1%BA%BFm-V%C3%B4-T%C3%ACnh-Online/316889155100550" target="_blank">
      <div class="fanpage">&nbsp;</div>
      </a> </div>
  </div>
  
  <div class="bottom-image">&nbsp;</div>
</div>
</body>
</html>
